<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>timming 函数</title>
</head>
<body>


<div id="numBox">0</div>
<div>
   <button id="btnStart">开始计数</button>
  <button id="btnClose">结束计数</button>
</div>

</body>

<script>

  /**
   *   1. 在页面上 呈现一个时间UI，每秒改变一次时间
   *   2. 模拟时钟
   * */

  var btnStart=  document.getElementById('btnStart');
  var btnClose=  document.getElementById('btnClose');

  var setCounter;// 复用

  btnStart.onclick = function (){
      setCounter=   setInterval(function (){

          var numBox= document.getElementById('numBox');
          var num =parseInt(numBox.innerText) ;
          num++;

          numBox.innerText = num;

      },1000)
  }

  btnClose.onclick =function (){

      clearInterval(setCounter)
  }




</script>

</html>